home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / QuickTime / ChromaKeyMovie / Sources / start.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-20  |  3.7 KB  |  182 lines  |  [TEXT/MPS ]

  1. /****************************************************/
  2. /*                                                     */
  3. /*    File:    start.c                                    */
  4. /*                                                    */
  5. /*    Program:    ChromaKeyMovie                         */
  6. /*                                                    */
  7. /*    By:        Jason Hodges Harris                        */
  8. /*                                                    */
  9. /*    Copyright:    © 1995 by Apple Computer, Inc.,        */ 
  10. /*                    all rights reserved.            */        
  11. /*                                                    */
  12. /****************************************************/
  13.  
  14.  
  15. // Mac Toolbox headers
  16.  
  17. #ifndef __CURSORCTL__
  18. #include <CursorCtl.h>
  19. #endif
  20.  
  21. #ifndef __DIALOGS__
  22. #include <Dialogs.h>
  23. #endif
  24.  
  25. #ifndef __FONTS__
  26. #include <Fonts.h>
  27. #endif
  28.  
  29. #ifndef __GESTALT__
  30. #include <Gestalt.h>
  31. #endif
  32.  
  33. #ifndef __MEMORY__
  34. #include <Memory.h>
  35. #endif
  36.  
  37. #ifndef __MENUS__
  38. #include <Menus.h>
  39. #endif
  40.  
  41. #ifndef __QDOFFSCREEN__
  42. #include <QDOffscreen.h>
  43. #endif
  44.  
  45. #ifndef __SEGLOAD__
  46. #include <SegLoad.h>
  47. #endif
  48.  
  49. #ifndef __TEXTEDIT__
  50. #include <TextEdit.h>
  51. #endif
  52.  
  53. #ifndef __TOOLUTILS__
  54. #include <ToolUtils.h>
  55. #endif
  56.  
  57. #ifndef __WINDOWS__
  58. #include <Windows.h>
  59. #endif
  60.  
  61.  
  62. // Program headers
  63.  
  64. #ifndef __CHROMAPPHEADER__
  65. #include "ChromaKeyMovie.app.h"
  66. #endif
  67.  
  68. #ifndef __CHROMAPROTOSHEADER__
  69. #include "ChromaKeyMovie.protos.h"
  70. #endif
  71.  
  72.  
  73. //    Global Variables
  74.  
  75. // Predefined RGBColors
  76.  
  77. RGBColor     kRGBWhite =    {0xFFFF,0xFFFF,0xFFFF},
  78.             kRGBBlack =    {0x0000,0x0000,0x0000},
  79.             gKeyColor;
  80. // Chroma keying mode
  81. short        gKeyMode;
  82. // location of the movie relative to the background image
  83. Boolean        gMovieBackGrnd;
  84. // Application loop exit test 
  85. Boolean        gDone;
  86. // Movie window open (only one window supported)
  87. Boolean        gMovieOpen;
  88.  
  89. // declare the QuickDraw globals for PowerMac native build
  90. #if defined(powerc) || defined(__powerc)
  91.     QDGlobals    qd;
  92. #endif
  93.  
  94.  
  95. // initialise the global variables
  96.  
  97. void InitGlobals(void)
  98. {
  99.     gKeyColor = kRGBBlack;        // preset chroma key color to black
  100.     gKeyMode = transparentMode;    // default Chroma key mode use transparent transfer mode
  101.     gMovieBackGrnd = false;        // movie in foreground
  102.     gDone = false;                // set global loop var to false while program active
  103.     gMovieOpen = false;            // No window open
  104. }
  105.  
  106.  
  107. // Gestalt tests
  108.  
  109. #pragma segment Main
  110. void TestforQuickTimeVersion(void)
  111. {
  112.     long    QTimeVersion;
  113.     OSErr    error;
  114.     if(Gestalt('qtim',&QTimeVersion) == noErr)
  115.     {
  116.              /* QuickTime version 2.1 or later required for all options to be available.
  117.                 If not display a warning dialog and disable QT 2.1 reliant feature */
  118.          if (QTimeVersion < 0x02100000)
  119.         {
  120.             DisplayAlert (rGenWarning,rQTmessages,2);
  121.             DisableItem(GetMHandle(mMode),iModifier); 
  122.         }
  123.  // check for the QuickTime shared library loaded as Gestalt not always correct
  124.  #if defined(powerc) || defined(__powerc)
  125.         if (!EnterMovies)
  126.         {
  127.             DisplayAlert(rGenAlert,rQTmessages,3);
  128.             gDone = true;
  129.             return;
  130.         }
  131. #endif
  132.         error = EnterMovies();    // initialise QuickTime
  133.         if (error != noErr)
  134.         {
  135.             DisplayAlert (rGenAlert,rQTmessages,1);
  136.             gDone = true;        // exit application
  137.         }
  138.         return;
  139.     }
  140.     DisplayAlert (rGenAlert,rQTmessages,1);
  141.     gDone = true;
  142.     return;
  143. }
  144.  
  145.  
  146. // Main function
  147.  
  148. #pragma segment Main
  149. int    main(void)
  150. {
  151.     long     *AppSize;                        // application size 
  152.     short    i;
  153.     
  154.     AppSize = (long*)(GetApplLimit());
  155.     SetApplLimit (AppSize-32768);
  156.  
  157.     // This decreases the application heap by 32k, which in turn
  158.     // increases the stack by 32k.
  159.  
  160.     MaxApplZone();    // Expand the heap so code segments load at the top.
  161.     for (i=0;i<5;i++)
  162.         MoreMasters();                // allocate more master pointers
  163.  
  164.     //      Initialise the toolbox
  165.  
  166.     InitGraf (&qd.thePort);
  167.     InitFonts();
  168.     InitWindows();
  169.     InitMenus();
  170.     TEInit();
  171.     InitDialogs(0L);
  172.     InitCursor();
  173.     
  174.     InitGlobals();                    // initialise globals
  175.     MenuBarInit();                    // init menubar
  176.     TestforQuickTimeVersion();        // test for and initialise Quicktime    
  177.     DoAdjustMenus();                 // menu setup
  178.     EventLoop();                    // Call the main event loop.
  179.     ExitToShell();                    // Quit the application.
  180.     return 0;
  181. }
  182.